<%@page contentType="text/html; charset=utf-8" language="java" %>
<%@page import="biz.UserBiz" %>
<%@page import="bean.User" %>
<html>
	<head>
		<link href="css.css" rel="stylesheet" type="text/css">
		<title>欢迎注册iWiki</title>
		<%
		String action = request.getParameter("action");
		if((action != null) && action.equals("reg")){
			User user = new User();
			request.setCharacterEncoding("UTF-8");
			user.setUname(request.getParameter("uname"));
			user.setUpass(request.getParameter("upass"));
			user.setUemail(request.getParameter("email"));
			user.setUinfo(request.getParameter("info"));
			boolean flag = UserBiz.insertUserByUser(user);
			if(flag){
				user = UserBiz.getUserByUname(user.getUname());
				session.setAttribute("uid",user.getUid());
				out.print("<script>alert('注册成功，即将转向您的页面！');history.back();</script>");
				response.sendRedirect("user.jsp");
			}else{
				out.print("<script>alert('重名用户已存在，请再选一个用户名吧！');history.back();</script>");
			}
		}
		%>
	</head>
	<body>
		<jsp:include page="/head.jsp"/>
		<div>
		<center><fieldset>
			<p class="f_title">注册iWiki帐号</p>
			<div class="disc">注册一个iWiki账号，创建自己的词条和关系</div>
			<form method="post" action="regist.jsp?action=reg">
				<ol>
				<li><label for="uname"><span id="blank">&nbsp;&nbsp;</span>用户名：</lable><span><input type="text" name="uname" class="input" style="width:180px;"></span></li>
				<li><label for="upass"><span id="blank">&nbsp;&nbsp;&nbsp;&nbsp;</span>密码：</label><span><input type="password" name="upass" class="input" style="width:180px;"></span></li>
				<li><label for="email">电子邮件：</label><span><input type="text" name="email" class="input" style="width:180px;"></span></li>
				<li><label for="info"><span id="blank">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="vertical-align:top">签名：</span></label><span><textarea type="text" name="info" class="input" style="width:180px;height:8em;"></textarea></span></li>
				</ol>
				<input type="submit" value="我要注册" style="width:80px" class="button"/>
				<input type="reset" value="重填" style="width:60px" class="button"/>	
			</form>
		</fieldset></center>
		</div>
		<jsp:include page="/copyright.html"/>
	</body>
</html>